package com.csust.travel.mapper;

import com.csust.travel.entity.Buyers;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface BuyersMapper {
    @Select("select * from buyers")
    List<Buyers> findAllItem();

    @Delete("delete from buyers where id = #{id}")
    void delItem(Integer id);

    @Insert("insert into buyers values(null,#{name},#{college},#{major},#{phonenumber},#{qqnumber},#{sex},#{buyer_code})")
    void saveItem(Buyers item);

    @Select("select * from buyers where id = #{id}")
    Buyers findOne(Integer id);

    @Update("update buyers set buyer_code=#{buyer_code},name=#{name},college =#{college},major=#{major} ,phonenumber=#{phonenumber},qqnumber=#{qqnumber},sex=#{sex} where id = #{id}")
    void editItem(Buyers item);

    @Select("select * from buyers where buyer_code = #{string} or name like concat('%',#{string},'%') or phonenumber =#{string}")
    List<Buyers> findByString(String string);
}
